package com.dailyblue.project.estate.controller;

import com.dailyblue.project.estate.commons.bean.ChargeDetail;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.service.ChargeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:ChargeDetailController
 * @Date:2025/9/18 13:58
 */
@RestController
@RequestMapping("/charge")
public class ChargeDetailController {
    @Resource
    private ChargeService chargeService;

    @PostMapping
    JsonResult saveChargeDetail(@RequestBody ChargeDetail chargeDetail) {
        return chargeService.saveChargeDetail(chargeDetail);
    }

    @GetMapping("/{id}")
    JsonResult findOne(@PathVariable("id")String id) {
        return chargeService.findOneById(id);
    }

    @GetMapping
    JsonResult findAll(){
        return chargeService.findAll();
    }

    @DeleteMapping("/{id}")
    JsonResult deleteOne(@PathVariable("id")String id) {
        return chargeService.deleteOneById(id);
    }

    @PutMapping
    JsonResult updateOne(@RequestBody ChargeDetail chargeDetail) {
        return chargeService.updateOneById(chargeDetail);
    }
}
